function t(t, h, e) {
    t = parseInt(t), h = parseInt(h), x.cutwdith = t, x.cutheight = h, x.origin.x = x.wdith / 2 - x.cutwdith / 2, 
    x.origin.y = x.height / 2 - x.cutheight / 2, x.cutimage.width = x.cutwdith, x.cutimage.height = x.cutheight, 
    wx.getImageInfo({
        src: e,
        success: function(t) {
            x.cutwdith, x.cutheight, t.width > t.height ? (x.cutimage.height = x.cutheight, 
            x.cutimage.width = x.cutimage.height / t.height * t.width) : (x.cutimage.width = x.cutwdith, 
            x.cutimage.height = x.cutimage.width / t.width * t.height), x.cutimage.x = x.wdith / 2 - x.cutimage.width / 2, 
            x.cutimage.y = x.height / 2 - x.cutimage.height / 2, x.cutimage.src = e, d = x.cutimage.width, 
            w = x.cutimage.height, i();
        }
    });
}

function i() {
    var t = !(arguments.length > 0 && void 0 !== arguments[0]) || arguments[0];
    h.drawImage(x.cutimage.src, x.cutimage.x, x.cutimage.y, x.cutimage.width, x.cutimage.height), 
    t && (h.setStrokeStyle("red"), h.strokeRect(x.origin.x, x.origin.y, x.cutwdith, x.cutheight)), 
    h.draw();
}

var h, e, g, c, u, a, d, w, m, n, o, s = {
    x: 0,
    y: 0
}, x = {
    wdith: 0,
    height: 0,
    origin: {
        x: 0,
        y: 0
    },
    cutwdith: 0,
    cutheight: 0,
    cutimage: {}
};

Page({
    data: {
        width: 0,
        height: 0
    },
    onLoad: function(i) {
        e = this, s = {
            x: 0,
            y: 0
        }, x = {
            wdith: 0,
            height: 0,
            origin: {
                x: 0,
                y: 0
            },
            cutwdith: 0,
            cutheight: 0,
            cutimage: {}
        }, m = 0, h = wx.createCanvasContext("CutCanvas"), wx.getSystemInfo({
            success: function(h) {
                x.wdith = h.windowWidth, x.height = h.windowHeight - 120, g = i.cutindex, e.setData({
                    width: x.wdith,
                    height: x.height
                });
                i.width > i.height ? (i.height = (x.wdith - 20) / i.width * i.height, i.width = x.wdith - 20, 
                i.height >= x.height && (i.width = (x.height - 20) / i.height * i.width, i.height = x.height - 20)) : (i.width = (x.height - 20) / i.height * i.width, 
                i.height = x.height - 20, i.width >= x.wdith && (i.height = (x.wdith - 20) / i.width * i.height, 
                i.width = x.wdith - 20)), t(i.width, i.height, i.path);
            }
        });
    },
    cutmovestar: function(t) {
        if (t.touches.length < 2) c = t.touches[0].x, u = t.touches[0].y; else {
            var i = t.touches[1].x - t.touches[0].x, h = t.touches[1].y - t.touches[0].y;
            n = x.cutimage.x, o = x.cutimage.y, a = Math.sqrt(i * i + h * h);
        }
    },
    cutimgmove: function(t) {
        if (t.touches.length < 2) {
            if (t.timeStamp - m < 1e3) return;
            x.cutimage.x = x.cutimage.x + (t.touches[0].x - c), x.cutimage.y = x.cutimage.y + (t.touches[0].y - u), 
            c = t.touches[0].x, u = t.touches[0].y, i();
        } else {
            m = t.timeStamp;
            var h = t.touches[1].x - t.touches[0].x, e = t.touches[1].y - t.touches[0].y, g = Math.sqrt(h * h + e * e) / a;
            x.cutimage.width = d * g, x.cutimage.height = w * g, g >= 1 ? (x.cutimage.x = n - (x.cutimage.width - d) / 2, 
            x.cutimage.y = o - (x.cutimage.height - w) / 2) : (x.cutimage.x = n + (d - x.cutimage.width) / 2, 
            x.cutimage.y = o + (w - x.cutimage.height) / 2), i();
        }
    },
    cutmoveend: function(t) {
        d = x.cutimage.width, w = x.cutimage.height;
    },
    cutimg: function() {
        i(!1);
        var t = 5;
        "weixincode" == g && (t = 1), wx.canvasToTempFilePath({
            canvasId: "CutCanvas",
            x: x.origin.x,
            y: x.origin.y,
            width: x.cutwdith,
            height: x.cutheight,
            destWidth: x.cutwdith * t,
            destHeight: x.cutheight * t,
            quality: 1,
            success: function(t) {
                wx.setStorageSync("cutpath", t.tempFilePath), wx.setStorageSync("cutindex", g), 
                wx.navigateBack({
                    delta: 1
                });
            }
        });
    }
});